cmake_minimum_required(VERSION 3.10)
set(PROJECT_N sproxy)
project(${PROJECT_N} VERSION 1.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
SET(DEBUF true)
# 源文件路径
file(GLOB_RECURSE SRCS ${PROJECT_SOURCE_DIR}/src/*.cpp)
# 默认头文件
SET(INCLUDES include)

if(${DEBUF})
    file(GLOB_RECURSE DEFAULT_HEADER ${PROJECT_SOURCE_DIR}/include/*.h)
    message(STATUS "==================================[default]==================================")
    message(STATUS "default header file:")
    foreach(header ${DEFAULT_HEADER})
        message(STATUS "\t\t${header}")
    endforeach()
    message(STATUS "default source file:")
    foreach(header ${DEFAULT_HEADER})
        message(STATUS "\t\t${header}")
    endforeach()
    message(STATUS "")
endif()


# 模块加载
MACRO(model_add model_name )
    set(SRC ${SRCS})
    # 头文件
    FILE(GLOB_RECURSE header_files ${model_name}/*.h ${model_name}/*.hpp ${model_name}/*.hxx)
    # 源文件
    FILE(GLOB_RECURSE source_files ${model_name}/*.c ${model_name}/*.cpp ${model_name}/*.cxx)
    SET(SRCS ${SRC} ${source_files})
    SET(INCLUDES ${INCLUDES} ${model_name})

    if(${DEBUF})
        message(STATUS "==================================[${model_name}]==================================")
        message(STATUS "header file:")
        foreach(header_file ${header_files})
            message(STATUS "\t\t${header_file}")        
        endforeach()
        # 输出源文件
        message(STATUS "source file:")
        foreach(source_file ${source_files})
            message(STATUS "\t\t${source_file}")        
        endforeach()
        message(STATUS "")
    endif()
ENDMACRO()

# 指定编译模块
model_add(src/core)
# model_add(src/http)
model_add(src/sshd)

# 日志输出级别不配置默认不输出, DEBUG > TRACE > INFO > WARN
add_compile_definitions(DEBUG)

# ssh 模式 
add_compile_definitions(SSH_MODEL_PROXY)

add_executable(${PROJECT_N} ${SRCS})
target_include_directories(${PROJECT_N} PUBLIC ${INCLUDES})
set(REQUEST_LIB ssh log4cxx pthread)
# 依赖库
target_link_libraries(${PROJECT_N} PRIVATE ${REQUEST_LIB})

